package com.gusto.engine.recommend.prediction;

import java.util.List;
import java.util.Map;

import org.apache.log4j.Logger;

import com.gusto.engine.colfil.Evaluation;
import com.gusto.engine.recommend.PredictionService;
import com.gusto.engine.recommend.prediction.base.BaseSemanticImpl;

/**
 * <p>Semantic algorithm, selects a semantic neighbor and computes the prediction.</p>
 * 
 * @author amokrane.belloui@gmail.com
 *
 */
public class SemanticImpl extends BaseSemanticImpl implements PredictionService {
	
	private Logger log = Logger.getLogger(getClass());
	
	protected Double doPrediction(List<? extends Evaluation> evalsSem, double user_mean, double item_mean, Map<Long, Double> usersWeightsSem, Map<Long, Double> itemsWeightsSem) {
		Double val = null;
		log.debug("Number of ratings in the submatrix " + evalsSem.size() + " should be >= " + this.minEvals);
		if (evalsSem.size() >= this.minEvals) {
			log.debug("Nb evals : " + evalsSem.size());
			val = this.buildPrediction(evalsSem, user_mean, item_mean, usersWeightsSem, itemsWeightsSem);
			//nb_pred_sem  ++;
		}
		return val;
	}
	
}
